package cn.ex;

import java.util.HashMap;

public class Ex6 {
    public static void main(String[] args) {
        HashMap<String, String> map = new HashMap<>();
        map.put("北京", "key存在的oldValue");
        map.put("上海", null);
        map.put("广州", "oldValue");
        map.put(null, "null的oldValue");
        map.putIfAbsent(null, "null的newValue");
        map.putIfAbsent("杭州", "key不存在的value");
        map.putIfAbsent("北京", "key存在的newValue");
        map.putIfAbsent("上海", "null值被覆盖");
        map.replace("广州", "replaceValue");
        map.replace("武汉", "key不存在的value");

        System.out.println(map);
    }

}
